package main

import (
	"fmt"
	"net/http"
	"yunpan/handler"
)

func main(){
	fmt.Println("上传服务开始工作")
	http.Handle("/static/",http.StripPrefix("/static/", http.FileServer(http.Dir("./static"))))
	http.HandleFunc("/file/upload",handler.HTTPInterceptor(handler.UploadHandler))
	http.HandleFunc("/file/upload/success",handler.UploadSuccess)
	http.HandleFunc("/file/meta",handler.GetFileMetaHandler)
	http.HandleFunc("/file/query",handler.HTTPInterceptor(handler.FileQueryHandler))
	http.HandleFunc("/file/download",handler.DownLoadHandler)
	http.HandleFunc("/file/update",handler.HTTPInterceptor(handler.FileMetaUpdateHandler))
	http.HandleFunc("/file/delete",handler.HTTPInterceptor(handler.FileDeleteHandler))
	http.HandleFunc("/file/fastupload",handler.HTTPInterceptor(handler.TryFastUploadHandler))

	http.HandleFunc("/file/mpupload/init", handler.HTTPInterceptor(handler.InitialMultipartUploadHandler))
	http.HandleFunc("/file/mpupload/uppart", handler.HTTPInterceptor(handler.UploadPartHandler))
	http.HandleFunc("/file/mpupload/complete", handler.HTTPInterceptor(handler.CompleteUploadHandler))

	http.HandleFunc("/file/downloadurl", handler.HTTPInterceptor(handler.DownloadURLHandler))
	http.HandleFunc("/file/getfileurl", handler.HTTPInterceptor(handler.GETDownloadURLHandler))

	http.HandleFunc("/user/signup",handler.SignupHandler)
	http.HandleFunc("/user/signin",handler.SignInHandler)
	http.HandleFunc("/user/info",handler.HTTPInterceptor(handler.UserInfoHandler))
	err := http.ListenAndServe(":8989", nil)
	if err != nil {
		fmt.Println(err.Error())
	}
}
